package com.example.jd.common;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;


@Component
@Transactional(rollbackFor = Exception.class)
public class SequenceNumUtil {

    public Long getNum() {
        return IdWorkerShort.nextId();
    }

    public String generateOrderNum() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate = sdf.format(new Date());
        return "DZ" + "_" + newDate + "_" + getNum();
    }

}
